<!-- 商品详情 -->
<template>
	<view class="detail-wrap ">
		<!-- 标题栏 -->
		<view class="nav-box">
			<view class="state-hack"></view>
			<view style="display: flex;flex-direction:row;height: 48px;width: 100%;justify-content: space-between;margin-top: 40rpx;">
				<view hover-class="back-hover" class="back-box u-m-x-30 u-flex u-row-center u-col-center">
					<view class="u-iconfont uicon-arrow-left" style="color: #fff;font-size:36rpx;" @tap="goBack">
					</view>
				</view>
			</view>
		</view>

		<!-- 缺省页 -->
		<ljshop-empty
		ref="uswiperRef"
		v-if="showEmpty"
		:image="'https://image.hzwltb69.com/app/date/2023/暂无商品.png'"
		:tipText="showEmptyText"
		btnText="返回上一页"
		@click="$Router.back()"
		:marginTop="`200rpx`"
		></ljshop-empty>
		<view class="detail_box" v-else>
			<view class="detail-content">
				<!-- 轮播 -->
				<u-swiper
				:height="750"
				borderRadius="0"
				:list="productImages"
				indicator-pos="bottomCenter"
				mode="number"
				:interval="3000"
				:video="goodsInfo.video"
				:autoplay="autoplay"
				@click="onGoodsSwiper"
				@changeAutoPlay="changeAutoPlay"
				>
				</u-swiper>
<!-- 					<view class="video-box" 
					v-if="video.length>0">
						<video 
						:autoplay="true" 
						show-mute-btn="false" 
						:muted="ismuted" 
						@play="isplay" 
						@pause="ispause"
						@ended="isstop" 
						@fullscreenchange="creenchange" 
						:src="video[0]" 
						show-fullscreen-btn="false"
						:loop="true" 
						:controls="true" 
						:show-center-play-btn="true" 
						:show-play-btn="true"
						@error="videoErrorCallback" 
						:enable-progress-gesture="false"
						 object-fit="fill"
						  ></video>
					</view> -->
                    <view class="rush-box" >
                        <view class="left" >
                            <view class="topPrice" >
                               <span style="font-size: 24rpx;font-weight: 500;">￥</span>
                                {{ activity.newPrice }}
                                <span class="sub">原价:{{ goodsInfo.price }}</span>
                            </view>
                            <view class="hot" >
                                <!-- 热销{{ activity.newSales }}件 -->
								<image class="ljshop-image" src="https://image.hzwltb69.com/app/date/2023/rushLogo.png" mode="widthFix">
									
								</image>
                            </view>
                        </view>
                        <view class="right" >
                            <view class="pross" >
                                <view class="line" :style="{width: (250 * (activity.percent / 100)) + 'rpx'}" >
                                    
                                </view>
                            </view>
                            <view class="times" >
                                距结束：{{ time }}
                            </view>
                        </view>
                    </view>
				<!-- 价格卡片组 -->
				<sh-price-card
				:detail="goodsInfo"
				:type="detailType"
				@change="getActivityRules"
				:subsidy="subsidy"
                :activity="true"
				></sh-price-card>
				<!-- 标题 -->
				<view style="flex-direction: row;display: flex;background: #fff;">
				<view class="u-m-b-10 title-box u-p-20 u-skeleton-fillet" style="width: 700rpx;">
					
					<view class="goods-title u-m-b-10 u-ellipsis-2">{{ goodsInfo.name }}</view>
					<view class="sub-title u-ellipsis-2">{{ goodsInfo.caption?goodsInfo.caption:"" }}</view>
					 
				</view>
				<view hover-class="back-share" class="back-box u-m-x-30 u-flex u-row-center u-col-center" style="background: #fff;" @tap="onShare">
					<image src="https://image.hzwltb69.com/app/images/detailshare.png"   style="color: #fff;font-size: 28rpx;width: 40rpx;height: 40rpx;"></image>
				</view>
				</view>
				<!-- 参与的活动 -->
				<!-- <sh-activity v-if="goodsInfo.activity_discounts_tags && goodsInfo.activity_discounts_tags.length" :detail="goodsInfo.activity_discounts"></sh-activity> -->
				<!-- 规格选择 -->
				<view class="sku-box" @tap="showSku = true">
					<view class="u-flex u-row-between u-col-center">
						<view class="u-flex">
							<text class="title">规格</text>
							<text class="tip">{{ currentSkuText || '请选择规格' }}</text>
						</view>
						<text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf;"></text>
					</view>
				</view>
        <view class="store-box">
          <view class="store-left">
            <view class="img-box" :style="{'background-color' : goodsInfo.store.logo ? '' : '#ff5555'}" >
              <view v-if="!goodsInfo.store.logo">{{goodsInfo.store.name.slice(0,1)}}</view>
              <image v-else class="ljshop-image" :src="goodsInfo.store.logo"></image>
            </view>
            <view class="title-boxs">
              <view>
                {{goodsInfo.store.name}}
              </view>
              <view style="font-size: 25rpx;margin-top: 10rpx;color: #818080">
                {{goodsInfo.store.favorites}}人关注 已售{{goodsInfo.store.sales}}
              </view>
            </view>
          </view>
          <view class="store-right" @tap="toStore(goodsInfo.store.id)">进店逛逛</view>
        </view>
        <!-- 评价 -->
        <view class="goods-comment" >
          <view v-if="commentList.length > 0" >
            <view class="top-box">
              <view class="title">用户评价({{commentNum}})</view>
            </view>
            <block v-for="comment in commentList" :key="comment.id">
              <sh-comment :comment="comment"></sh-comment>
            </block>
            <view class="bottom-box" @tap="jump('/pages/goods/comment/comment-list', { goodsId: goodsInfo.id })">
              <view class="all">查看全部用户评价</view>
              <view class="more">共
                <span style="margin: 0 10rpx 0 10rpx">{{commentNum}}</span>
                条</view>
            </view>
          </view>
<!--          <ljshop-empty-->
<!--              v-else-->
<!--              marginTop="20rpx"-->
<!--              tipText="暂无评价~">-->
<!--          </ljshop-empty>-->
          <view v-else style="background-color: #fff;padding-left: 20rpx;margin-bottom: 10rpx;height: 100rpx;line-height: 100rpx;font-size: 30rpx;font-weight: 600"> 暂无评价</view>
<!--          <view class="more-box u-flex u-row-center u-col-center">-->
<!--            <button class="u-reset-button more-btn u-flex u-row-center u-col-center"-->
<!--                    @tap="jump('/pages/goods/comment/comment-list', { goodsId: goodsInfo.id })">-->
<!--              查看全部-->
<!--              <view class="u-iconfont uicon-arrow-right" style="color:#d5a65a ;font-size: 28rpx;">-->
<!--              </view>-->
<!--            </button>-->
<!--          </view>-->
        </view>


        <view class="top-box">
          <view class="title" style="font-size: 28rpx">产品详情</view>
        </view>
				<view class="tab-detail u-p-20 u-m-b-10">
					<!-- 详情富文本 -->
					<view class="rich-box">
						<u-parse :html="goodsInfo.introduction"></u-parse>
					</view>
					<!-- 参数 -->
					<view class="goods-size" v-if="tabCurrent === 'tab1'">
						<view class="table-box" v-if="goodsInfo.parameterValues && goodsInfo.parameterValues.length">
							<view class="t-tr u-flex" v-for="t in setparameter(goodsInfo.parameterValues)"
								:key="t.title">
								<view class="t-head u-flex" v-if="!t.name">{{ t }}</view>
								<view class="t-head u-flex" v-if="t.name">{{ t.name }}</view>
								<view class="t-detail" v-if="t.value">{{ t.value }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>



			<!-- 商品foot -->
			<view class="tabbar-foot safe-area-inset-bottom" v-if="goodsInfo.id">
				<view class="detail-foot_box safe-area-inset-bottom  u-flex u-col-ceter u-row-around">
					<!-- foot左侧 -->
					<view class="left u-flex">
						<!-- 积分foot -->
						<view class="tools-item u-flex-col u-row-center u-col-center" @tap="toStore(store.id)">
							<image class="tool-img ljshop-selector-circular"
								src="https://image.hzwltb69.com/app/date/2023/我的店铺.png" mode=""></image>
							<text class="tool-title ljshop-selector-rect">店铺</text>
						</view>
						<!-- 非积分foot -->
						<block v-if="detailType !== 'score'">
							<view class="tools-item u-flex-col u-row-center u-col-center"
								@tap="onFavorite(goodsInfo.id)">
								<image class="tool-img"
									:src="isProductFavorite ? 'https://image.hzwltb69.com/app/date/2023/收藏选中.png' : 'https://image.hzwltb69.com/app/date/2023/收藏.png'"
									mode=""></image>
								<text class="tool-title">收藏</text>
							</view>
							<view class="tools-item u-flex-col u-row-center u-col-center"  @tap="kefu(store.business.id,store.logo,store.name,store.id,goodsInfo)" >
								<image class="tool-img" src="https://image.hzwltb69.com/app/date/2023/信息.png" mode=""></image>
								<text class="tool-title">客服</text>
							</view>
						</block>
					</view>
					<!-- foot右侧 -->
					<view class="detail-right">
						<!-- 积分按钮 -->
						<view class="detail-btn-box" v-if="detailType === 'score'"><button
								class="u-reset-button  score-btn" @tap="goPay">立即兑换</button></view>
						<view v-if="detailType !== 'score'">
							<!-- 正常按钮 -->
							<!-- #ifdef MP-WEIXIN -->
							<view class="detail-btn-box u-flex u-row-around" v-if="hasLogin">
								<button
								class="u-reset-button tool-btn2 pay-btn ljshop-btn onSubsidy"
                                :style="{'background': activity.canBuy ? 'rgba(248, 47, 47, 1)' : '#bfbfbf'}"
								@tap="goPay"
								>
                                {{ activity.canBuy ? '立即秒杀' : '已购买' }}
                            </button>
							</view>
							
							<view class="detail-btn-box u-flex u-row-around" v-if="!hasLogin" >
								<button class="u-reset-button tool-btn3  pay-btn" v-show="!hasLogin"
									style="text-align: center;" open-type="getPhoneNumber"
									@getphonenumber="onGetPhoneNumber">{{ '登录/注册' }}</button>
							</view>
							<!-- #endif -->
							<!-- #ifdef APP-PLUS || H5 -->
							<view class="detail-btn-box u-flex u-row-around" >
								<button
								 class=" u-reset-button tool-btn2 pay-btn ljshop-btn onSubsidy"
                                 :style="{'background': activity.canBuy ? 'rgba(248, 47, 47, 1)' : '#bfbfbf'}"
								 @tap="goPay">
                                  {{ activity.canBuy ? '立即秒杀' : '已购买' }}
                                </button>
							</view>
							 	<!-- #endif -->
							<!-- 活动按钮 -->
							<view class="detail-btn-box u-row-around"
								v-if="activityRules.status && goodsInfo.activity_type">
								<button class=" u-reset-button seckilled-btn" v-if="activityRules.status !== 'ing'">
									<text v-if="activityRules.status == 'waiting'">暂未开始</text>
									<text v-if="activityRules.status == 'end'">已结束</text>
								</button>
								<block v-else>
									<!-- 活动中，秒杀 -->
									<button class=" u-reset-button  seckill-btn"
										v-if="goodsInfo.activity && goodsInfo.activity.type === 'seckill'"
										@tap="goSeckill">
										立即秒杀
									</button>
									<!-- 活动中，拼团 -->
									<view class="u-flex groupon-btn-box"
										v-if="goodsInfo.activity && goodsInfo.activity.type === 'groupon'">
										<button
											class="tool-btn u-reset-button add-btn u-flex-col u-row-center u-col-center"
											@tap="payGroupon" v-if="goodsInfo.activity.rules.is_alone === '1'">
											<text class="price font-OPPOSANS">￥{{ goodsInfo.price }}</text>
											<text class="price-title">单独购买</text>
										</button>
										<button
											class=" tool-btn u-reset-button groupon-btn u-flex-col u-row-center u-col-center"
											:style="goodsInfo.activity.rules.is_alone === '0' ? 'width:400rpx' : ''"
											@tap="payGroupon('groupon')">
											<text class="price font-OPPOSANS">￥{{ goodsInfo.groupon_price }}</text>
											<text class="price-title">我要开团</text>
										</button>
									</view>
								</block>
							</view>
						</view>
					</view>
				</view>
			</view>
		 

			<!-- 规格弹窗 -->
			<ljshop-sku v-if="showSku"
			v-model="showSku"
			:goodsInfo="goodsInfo"
             :minNum="minNum"
             :setup="setup"
             :newPrice="activity.newPrice"
			:activityRules="activityRules"
			:buyType="goodsInfo.activity_type == 'seckill' || detailType === 'score' ? 'buy' : buyType"
			:grouponBuyType="grouponBuyType"
			:goodsType="detailType === 'score' ? 'score' : 'goods'"
			@changeType="changeType"
			@getSkuText="getSkuText"
			:disabled="true"
			></ljshop-sku>

			<!-- 	分享组件 -->
			<ljshop-share v-model="showShare" :posterInfo="goodsInfo" :posterType="'goods'"></ljshop-share>
		 
		</view>
	</view>
</template>

<script>
	let systemInfo = uni.getSystemInfoSync();

	import shPriceCard from '../components/sh-price-card.vue';
	import shServe from '../components/sh-serve.vue';
	import shComment from '../components/sh-comment.vue';
	import share from '@/ljshop/share';

	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		components: {
			shServe,
			shPriceCard,
			shComment,
		},
		data() {
			return {
				// navbar
				backIconName: 'arrow-left',
				showSku: false, //是否显示规格弹窗
				currentSkuText: '', //选中规格
				detailType: '',
				showShare: false,
				buyType: 'sku',
				grouponBuyType: 'alone', //拼团购买方式。
				showEmpty: false,
				showEmptyText: '',
				showServe: false,
                time: '00:00:00',
				goodsInfo: {
					paySales: 0,
          store:{
            logo: null,
            name: '',
            favorites: 0,
            sales: 0,
          }
				},
				goodsInfoAll: {},
				commentList: [
        ], //商品评价列表
				commentNum: 0, //商品评价总数
				favorite: false,
				store: {},
				activityRules: {},
				currentSkuList: [],
				confirmGoodsInfo: {},
				swiperCurrent: 0, //轮播下标
				tabCurrent: 'tab0',
				tabList: [{
						id: 'tab0',
						title: '商品详情'
					},
					// {
					// 	id: 'tab1',
					// 	title: '规格参数'
					// },
					{
						id: 'tab2',
						title: '用户评价'
					}
				],
				productImages: [],
				isProductFavorite: false,
				isStoreFavorite: false,
				productId: '',
				beiinvcode: "",
				playing: false,
				pause: true,
				isautoplay: true,
				isshow: true,
				isvideo: true,
				ismuted: true,
				isvideoplay: true,
				autoplay: true,
				video:['https://image.hzwltb69.com/video/media/2022/11/459b21f3bcb54f6588a60f8adefa78b9.mp4?size=720x1280'],
				hasLogin:uni.getStorageSync("UId")>0?true:false,
				userinfo:{},
				ownerId:0,
				subsidy: false,
                minNum: 1,
                setup: 1,
                intervall: null,
                activity: {},
                END_TIME: null
			};
		},
		// 是否登录
		computed: {
			...mapGetters(['isLogin', 'authType']),
			navbarHeight() {
				// #ifdef APP-PLUS || H5
				return 48;
				// #endif
				// #ifdef MP
				let height = systemInfo.platform == 'ios' ? 44 : 48;
				return height;
				// #endif
			}
		},
		async onLoad() {
			let that = this;
            console.log(that.$Route.query);
            var pages = getCurrentPages();
			var page = pages[pages.length - 1];
			this.backIconName = getCurrentPages().length > 1 ? 'arrow-left' : 'home-fill';
			const type = this.$Route.query.type;
            pages[0].options.productId > 0
             ?
                this.productId = pages[0].options.productId
             :
                this.productId = that.$Route.query.id;
            
			that.ownerId = that.$Route.query.ownerId;
			this.detailType = type;
			if(that.$Route.query.subsidy){
				that.subsidy = true
			}
			switch (type) {
				case 'score':
					await this.getScoreDetail();
					break;
				default:
					await this.getGoodsDetail();
			}
		},
		onShow() {
				// #ifdef APP-PLUS 
				
			let platform = uni.getSystemInfoSync().platform

			if (platform == "android") {
				
				this.requestStag()
			}
			// #endif

		},
		// 监听页面卸载 清空分享
		onUnload() {
			share.setShareInfo();
        clearInterval(this.intervall);
		},

		methods: {
        getTime(){
            let date = new Date();
            let now = date.getTime();
            let targetTime = new Date(date.toDateString() + " " + this.END_TIME);
            if (targetTime.getTime() < now) {
            targetTime.setDate(targetTime.getDate() + 1);
            }
            let time = (targetTime.getTime() - now) / 1000;
            let h = Math.floor(time / 3600);
            let m = Math.floor((time % 3600) / 60);
            let s = Math.floor(time % 60);
            let formattedTime =
             `
            ${h.toString().padStart(2, '0')}:
            ${m.toString().padStart(2, '0')}:
            ${s.toString().padStart(2, '0')}
            `;
            this.time = formattedTime;
        },
			requestStag() {
				plus.android.requestPermissions(['android.permission.READ_EXTERNAL_STORAGE',
					'android.permission.WRITE_EXTERNAL_STORAGE', 'android.permission.READ_PHONE_STATE'
				], function(e) {
					if (e.deniedAlways.length > 0) { //权限被永久拒绝
						// 弹出提示框解释为何需要定位权限，引导用户打开设置页面开启
						//console.log('Always Denied!!! ' + e.deniedAlways.toString());
						return
					}
					if (e.deniedPresent.length > 0) { //权限被临时拒绝
						// 弹出提示框解释为何需要定位权限，可再次调用plus.android.requestPermissions申请权限
						//console.log('Present Denied!!! ' + e.deniedPresent.toString());
						return
					}
					if (e.granted.length > 0) { //权限被允许
						//调用依赖获取定位权限的代码
						//console.log('Granted!!! ' + e.granted.toString());
						return
					}
				}, function(e) {
					//console.log('Request Permissions error:' + JSON.stringify(e));
				});

			},
			// goBack
			// 微信直播商品跳转详情，需要用小程序原生接口才能返回。
			goBack() {
				console.log('返回首页');
				uni.reLaunch({
					url:'/pages/index/index'
				})
			},
			setparameter(parameter) {
				let paramList = [];
				let that = this;
				for (let i = 0; i < that.goodsInfo.parameterValues.length; i++) {
					if (that.goodsInfo.parameterValues[i].group) {
						paramList.push(that.goodsInfo.parameterValues[i].group);
					}
					if (that.goodsInfo.parameterValues[i].entries.length > 0) {
						for (let k = 0; k < that.goodsInfo.parameterValues[i].entries.length; k++) {
							if(that.goodsInfo.parameterValues[i].entries[k].isSelected){
								paramList.push(that.goodsInfo.parameterValues[i].entries[k]);
							}
						}
					}
				}
				return paramList;
			},

			// 轮播图预览
			onGoodsSwiper(e) {
				let imglist =[];
				for (let i=0 ;i<this.goodsInfo.productImages.length;i++) {
					imglist.push(this.goodsInfo.productImages[i].source)
				}
				this.$tools.previewImage(imglist, e);
			},
			getActivityRules(e) {
				if (e) {
					this.activityRules = JSON.parse(e);
				}
			},
			// 检测
			checkActivity(data, type) {
				if (data) {
					return !data.includes(type);
				}
				return true;
			},
			// 路由跳转
			jump(path, parmas) {
				this.showShare = false;
				this.$Router.push({
					path: path,
					query: parmas
				});
			},
			// 回到首页
			goHome() {
				this.$Router.replaceAll('/pages/index/index');
			},

			// 选项卡
			onTab(id) {
				this.tabCurrent = id;
			},
			// 积分详情
			getScoreDetail() {
				let that = this;
				return new Promise((resolve, reject) => {
					that.$http('goods.scoreDetail', {
						id: that.$Route.query.id
					}).then(res => {

						if (res.code === 1) {
							that.goodsInfo = res.data;
							resolve(res.data);
						}
						if (res.code == 0) {
							resolve(false);
							that.$u.toast(res.msg);
						}
					});
				});
			},
			// 视频播放 滑动暂停
			changeAutoPlay(){
				this.autoplay = false
			},
			// 商品详情
			getGoodsDetail() {
				let that = this;
				uni.showLoading({

				})
				return new Promise((resolve, reject) => {
					that.$http(
						'goods.oldDetail', {
							productId: that.productId,
							UId: uni.getStorageSync("UId")
						},
						'正在加载中',
						true
					).then(res => {
						uni.hideLoading()
						if (res.code === 1) {
                            that.activity = res.activity
                            this.END_TIME = that.activity.endDate.substring(that.activity.endDate.length-5,that.activity.endDate.length)
                            this.intervall = setInterval(() => {
                                this.getTime();
                            }, 1000);
                            that.showEmpty = false;
							that.goodsInfoAll = res;
							that.isProductFavorite = res.isProductFavorite;
							that.isStoreFavorite = res.isStoreFavorite;
							that.goodsInfo = res.product;
							if(that.goodsInfo.specificationItems.length == 2){
								for(var a in that.goodsInfo.specificationItems[1].entries){
									that.goodsInfo.specificationItems[1].entries[a].pid = [0,0]
									that.goodsInfo.specificationItems[1].entries[a].disabled = false
									that.goodsInfo.specificationItems[1].entries[a].stockDisabled = false
								}
							}
							that.goodsInfo.Sku = res.Sku;
							that.goodsInfo.activitySku = res.activitySku
                            that.minNum = res.Sku[0].buyNum.minNum;
                            that.setup = res.Sku[0].buyNum.stepNum;
							that.store = res.store;
							if(res.videoUrl){
								that.goodsInfo.video = [res.videoUrl]
							}
							console.log(that.goodsInfo);
							if (that.goodsInfo.activity_type) {
								that.activityRules.status = that.goodsInfo.activity.status_code;
							}
							for (let i = 0; i < that.goodsInfo.productImages.length; i++) {
								that.productImages.push(that.goodsInfo.productImages[i].source)

							}
							if (res.rebate >= 0) {
								that.goodsInfo.rebate = res.rebate;

							}
							share.setShareInfo({
								title: that.goodsInfo.name,
								desc: that.goodsInfo.name,
								image: that.goodsInfo.large,
								//path:"/pages/goods/wxminidetail",
								path:"/pages/goods/rushbuy/rushdetail?InvitationCode=" + uni.getStorageSync("InvitationCode")+"&shareUId="+uni.getStorageSync("UId")+"&productId=" + that.$Route.query.id,
								params: {
									price: that.goodsInfo.price,
									subsidy:((that.goodsInfo.price-that.goodsInfo.cost)*res.rebate/100).toFixed(2),
									InvitationCode:uni.getStorageSync("InvitationCode"),
									shareUId:uni.getStorageSync("UId")
								}
							});
							that.getCommentList();
							resolve(res.data);
						} else {
							resolve(false);
							// that.$u.toast(res.msg);
							that.showEmpty = true;
							that.showEmptyText = res.msg;
						}
					});
				});
			},
			// 商品评论
			getCommentList() {
				let that = this;
				that.$http('goods.commentList', {
					productId: that.goodsInfo.id,
					page: 0,
          size: 2
				}).then(res => {
					if (res.code === 1) {
						that.commentList = res.data;
						that.commentNum = res.total;
					}
				});
			},
			// 组件返回的type;
			changeType(e) {
				this.buyType = e;
			},
			// 组件返回的规格;
			getSkuText(e) {
				this.currentSkuText = e;
			},
			// 分享
			onShare() {
				// uni.showToast({
				// 	"正在开发中"
				// })
				this.showShare = true;
			},
			// 加入购物车
			addCart() {
				if (uni.getStorageSync("UId")) {
					this.buyType = 'cart';
					// #ifdef APP-PLUS
					this.$refs.uswiperRef.videoPause()
					// #endif
					this.showSku = true;
				} else {
					// #ifdef MP-WEIXIN
					uni.showToast({
						title: '请先到个人中心登录',
						icon: 'none'
					});
					// #endif

					// #ifdef APP-PLUS
					uni.navigateTo({
						url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
					})
					// #endif
				}
			},
			// 立即购买
			goPay() {
                if(!this.activity.canBuy) return
				if (uni.getStorageSync("UId")) {
					this.buyType = 'buy';
					// #ifdef APP-PLUS
					this.$refs.uswiperRef.videoPause()
					// #endif
					this.showSku = true;
				} else {

					// #ifdef MP-WEIXIN
					uni.showToast({
						title: '请先到个人中心登录',
						icon: 'none'
					});
					// #endif

					// #ifdef APP-PLUS
					uni.navigateTo({
						url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
					})
					// #endif
				}


			},
			// 拼团购买
			payGroupon(type) {
				if (this.isLogin) {
					if (type === 'groupon') {
						this.grouponBuyType = 'groupon';
					} else {
						this.grouponBuyType = 'alone';
					}
					this.buyType = 'buy';
					// #ifdef APP-PLUS
					this.$refs.uswiperRef.videoPause()
					// #endif
					this.showSku = true;
				} else {

				}
			},

			// 立即秒杀
			goSeckill() {

			},

			// 收藏
			onFavorite(goodsId) {
				if(this.isProductFavorite === false) {
					if (uni.getStorageSync("UId")) {
						let that = this;
						that.$http('goods.addfavorite', {
							productId: goodsId
						}).then(res => {
							that.getGoodsDetail();
						});
					} else {
						// #ifdef MP-WEIXIN
						uni.showToast({
							title: '请先到个人中心登录',
							icon: 'none'
						});
						// #endif
					
						// #ifdef APP-PLUS
						uni.navigateTo({
							url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
						})
						// #endif
					}
				}else if(this.isProductFavorite === true) {
					this.$http('goods.favoriteDelete',{
						productId: goodsId,
					}).then(res => {
						this.getGoodsDetail();
					})
				}
			},
			toStore(stroeId) {
				if(this.ownerId > 0){
					this.$Router.push({
						path: '/pages/goods/smaillHome',
						query: {
							ownerId: this.ownerId
						}
					})
				}else{
					uni.setStorageSync("detailStoreId", stroeId)
					this.$Router.push({
						path: '/pages/store/index',
						query: {
							id: stroeId
						}
					})
				}
				
				// this.$http(
				// 	'store.getdetailcount', {
				// 		storeId: stroeId
				// 	},
				// ).then(res => {
				// 	uni.hideLoading()

				// 	if (res.code === 1) {
				// 		uni.setStorageSync("detailStoreId",stroeId)
				// 		if (res.storenavigationListcount === 0 && res.storeproducttagListcount === 0 && res
				// 			.storeAdImageListcount === 0) {
				// 			this.$Router.push({
				// 				path: '/pages/store/list',
				// 				query: {
				// 					id: stroeId
				// 				}
				// 			})
				// 		} else {

				// 		}
				// 	} else {

				// 	}
				// });
			},
			kefu(Id,logo,name,storeid,goods) {
				console.log(goods,'================================');
				let params = {
					name:goods.name,
					id: goods.id,
					price: goods.defaultSku.price,
					rebate: goods.defaultSku.rebate,
					img:goods.productImages[0].source,
				}
				if (uni.getStorageSync("UId")) {
					// #ifdef APP-PLUS
					let that = this;
					this.$Router.push({
							path: '/pages/kefu/minikefu',
						//path: '/pages/kefu/index',
						query: {
							id: storeid,
							businessId: goods.store.business.id,
							logo:logo ? logo : '',
							name: name,
							storeid,
							goods:params
						}
					})
					// #endif
					// #ifdef MP-WEIXIN ||H5
					let that = this;
					this.$Router.push({
							path: '/pages/kefu/minikefu',
						//path: '/pages/kefu/index',
						query: {
							id: storeid,
							logo:logo ? logo : '',
							businessId: goods.store.business.id,
							name:name,
							storeid,
							goods:params
						}
					})
					// #endif
					
				} else {
					// #ifdef MP-WEIXIN
					uni.showToast({
						title: '请先到个人中心登录',
						icon: 'none'
					});
					// #endif
				
					// #ifdef APP-PLUS
					uni.navigateTo({
						url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
					})
					// #endif
				}
				
				
			},
			isplay: function() {
				this.playing = true
				this.pause = false
				this.isautoplay = false;
			},
			ispause: function() {
				this.pause = true
				this.playing = false
				this.isautoplay = true;
			},
			isstop: function() {
				this.isautoplay = true;
			},
			
			onGetPhoneNumber(e) {
				let that = this
			
			
				that.getCode(e.detail.iv, e.detail.encryptedData);
			
			},
			getCode(iv, encryptedData) {
				let that = this
				uni.login({
					"provider": "weixin",
					"onlyAuthorize": true,
					success: async e => {
						if (e.errMsg == 'login:ok') {
							that.$http('user.weixingetMobile', {
								code: e.code,
								iv: iv,
								encryptedData: encryptedData
							}).then(res => {
			
								let openId = res.openId
								let mobile = res.userInfo.phoneNumber
								uni.setStorageSync("openId", openId)
			
								that.wxlogin(openId, mobile);
								//that.wxlogin(openId, 15903264045);
			
							});
						}
			
					},
					fail: async (err) => {
						uni.hideLoading()
					}
				})
			},
			wxlogin(openId, mobile) {
				let that = this
				let invCode = ""
			
			
				that.$http('user.weixinminilogin', {
					openId: openId,
					invCode: that.beiinvcode,
					mobile: mobile
				}).then(res => {
					this.hasLogin = true
					that.userinfo = res.user
					uni.setStorageSync("userinfo", that.userinfo)
					uni.setStorageSync("UId", that.userinfo.id)
					uni.setStorageSync("token", that.userinfo.id)
					uni.setStorageSync("isLogin", true)
					uni.setStorageSync("InvitationCode", res.InvitationCode);
					 
				});
			
			},
			

		}
	};
</script>

<style lang="scss">
	// 标题栏
	.video-box {
		width: 180rpx;
		height: 300rpx;
		overflow: hidden;
		position: absolute;
		background-color: #fff;
		border-radius: 6rpx;
		right: 0;
		top: 450rpx;
		z-index: 999;
	 
	}
	.nav-box {
		position: fixed;
		width: 100%;
		min-height: 140rpx;
		z-index: 888;
		top: 0;

		.back-box {
			background-color: rgba(#000, 0.18);
			width: 60rpx;
			height: 60rpx;
			border-radius: 50%;
			margin-top: 14rpx;
		}

		.back-hover {
			background-color: rgba(#fff, 0.18);
		}

		.back-share {
			background-color: rgba(#fff, 0.18);
		}

		.state-hack {
			width: 100%;
			height: var(--status-bar-height);
			/* #ifdef H5 */
			height: 20rpx;
			/* #endif */
		}
	}

	// 拼团玩法
	.groupon-play {
		background: #fff;
		line-height: 94rpx;

		.title {
			font-size: 28rpx;
			color: #999;
		}

		.description {
			font-size: 28rpx;
			width: 500rpx;
			margin-left: 30rpx;
		}
	}

	// 选项卡
	.tab-box {
		height: 102rpx;
		background: #fff;
		border-bottom: 1rpx solid rgba(#dfdfdf, 0.8);
		margin-top: 10rpx;

		.tab-item {
			flex: 1;
			height: 100%;
			position: relative;
			font-size: 30rpx;
			font-weight: bold;

			.tab-line {
				width: 123rpx;
				height: 4rpx;
				left: 50%;
				bottom: 0;
				transform: translateX(-50%);
				background: transparent;
				position: absolute;
				z-index: 2;
			}

			.line-active {
				background: rgba(168, 112, 13, 1);
			}
		}
	}

	// 选项卡内容
	.tab-detail {
		min-height: 400rpx;
		background: #fff;

		// 规格参数
		.goods-size {
			.table-box {
				width: 710rpx;
				margin: auto;
				background: rgba(255, 255, 255, 1);
				border: 1rpx solid rgba(223, 223, 223, 1);

				.t-tr {
					border-bottom: 1rpx solid rgba(223, 223, 223, 1);

					&:last-child {
						border-bottom: none;
					}

					.t-head {
						font-size: 26rpx;
						color: #999;
						flex: 1;
						padding: 15rpx 20rpx;
						height: 100%;
					}

					.t-detail {
						font-size: 26rpx;
						border-left: 1rpx solid rgba(223, 223, 223, 1);
						flex: 4;
						padding: 15rpx 20rpx;
						height: 100%;
					}
				}
			}
		}

		// 富文本
		.rich-box {
			/deep/ img {
				display: block;
			}
		}
		// 评论
		.goods-comment {
			.more-box {
				height: 100rpx;
				background: #fff;

				.more-btn {
					width: 200rpx;
					line-height: 60rpx;
					border: 1rpx solid rgba(213, 166, 90, 1);
					border-radius: 30rpx;
					font-size: 26rpx;
					font-weight: 400;
					color: rgba(168, 112, 13, 1);
					padding: 0;
					background: #fff;
				}
			}
		}
	}

	// 规格卡片
	.sku-box {
		line-height: 82rpx;
		background: #fff;
		padding: 0 20rpx;
		margin: 10rpx 0;
		font-size: 28rpx;
    border-radius: 30rpx;
		.title {
			
			color: #999;
			margin-right: 20rpx;
		}
	}

	// 标题卡片
	.title-box {
		background-color: #fff;

		.goods-title {
			font-size: 30rpx;
			font-weight:550;
			line-height: 42rpx;
			color: #0c0c0c;
		}

		.sub-title {
			color: #666;
			font-size: 24rpx;
			line-height: 42rpx;
		}
	}

	// 底部工具栏
	.tabbar-foot {
		min-height: 100rpx;
		width: 100%;
	}

	.detail-foot_box {
		min-height: calc(100rpx + env(safe-area-inset-bottom));
		border-top: 1rpx solid rgba(238, 238, 238, 1);
		background-color: #fff;
		width: 100%;
		position: fixed;
		bottom: 0;
		z-index: 999;

		.left,
		.detail-right {
			flex: 1;
		}

		.tools-item {
			flex: 1;
			height: 100%;

			.tool-img {
				width: 56rpx;
				height: 56rpx;
			}

			.tool-title {
				font-size: 22rpx;
				line-height: 22rpx;
				padding-top: 8rpx;
				color: #666;
			}
		}

		.detail-btn-box {
			flex: 1;

			.tool-btn {
				font-size: 28rpx;
				font-weight: 500;
				color: rgba(#fff, 0.9);
				width: 210rpx;
				min-height: 70rpx;
				// border-radius: 35rpx;
				border-bottom-left-radius: 35rpx;
				border-top-left-radius: 35rpx;
				border-top-right-radius: 0rpx;
				border-bottom-right-radius: 0rpx;
				
				padding: 0;
			 
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.price {
					font-size: 24rpx;
					line-height: 24rpx;
					font-weight: bold;
					color: rgba(#fff, 0.9);
				}

				.price-title {
					font-size: 20rpx;
					line-height: 20rpx;
					font-weight: 500;
					color: rgba(#fff, 0.9);
					padding-top: 8rpx;
				}
			}
			.tool-btn2 {
				font-size: 28rpx;
				font-weight: 500;
				color: rgba(#fff, 0.9);
				width: 210rpx;
				min-height: 70rpx;
				// border-radius: 35rpx;
				border-bottom-right-radius: 35rpx;
				border-top-right-radius: 35rpx;
				border-top-left-radius: 0rpx;
				border-bottom-left-radius: 0rpx;
				padding: 0;
				margin-right: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
			
				.price {
					font-size: 24rpx;
					line-height: 24rpx;
					font-weight: bold;
					color: rgba(#fff, 0.9);
				}
			
				.price-title {
					font-size: 20rpx;
					line-height: 20rpx;
					font-weight: 500;
					color: rgba(#fff, 0.9);
					padding-top: 8rpx;
				}
			}
			
			.tool-btn3 {
				font-size: 28rpx;
				font-weight: 500;
				color: rgba(#fff, 0.9);
				width: 420rpx;
				min-height: 70rpx;
				// border-radius: 35rpx;
				border-radius: 35rpx;
				padding: 0;
				margin-right: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
			
				.price {
					font-size: 24rpx;
					line-height: 24rpx;
					font-weight: bold;
					color: rgba(#fff, 0.9);
				}
			
				.price-title {
					font-size: 20rpx;
					line-height: 20rpx;
					font-weight: 500;
					color: rgba(#fff, 0.9);
					padding-top: 8rpx;
				}
			}

			.add-btn {
				background: #F7B655;
			}

			.pay-btn {
				background: #F3A326;
			}

			.score-btn {
				width: 600rpx;
				line-height: 80rpx;
				background: linear-gradient(90deg, rgba(49, 133, 243, 1), rgba(80, 205, 242, 1));
				box-shadow: 0px 7px 6px 0px rgba(80, 205, 242, 0.2);
				border-radius: 40rpx;
				font-size: 30rpx;

				font-weight: 500;
				color: rgba(255, 255, 255, 1);
				margin-right: 20rpx;
			}

			.seckill-btn {
				width: 432rpx;
				line-height: 70rpx;
				background: linear-gradient(93deg, rgba(208, 19, 37, 1), rgba(237, 60, 48, 1));
				box-shadow: 0px 7rpx 6rpx 0px rgba(#ed3c30, 0.22);
				font-size: 28rpx;

				font-weight: 500;
				color: rgba(255, 255, 255, 1);
				border-radius: 35rpx;
				padding: 0;
				margin-right: 20rpx;
			}

			.seckilled-btn {
				width: 432rpx;
				line-height: 70rpx;
				background: rgba(221, 221, 221, 1);
				font-size: 28rpx;

				font-weight: 500;
				color: #999999;
				border-radius: 35rpx;
				padding: 0;
				margin-right: 20rpx;
			}

			.groupon-btn {
				width: 210rpx;
				height: 70rpx;
				background: linear-gradient(90deg, rgba(254, 131, 42, 1), rgba(255, 102, 0, 1));
				box-shadow: 0px 7rpx 6rpx 0px rgba(255, 104, 4, 0.22);
				border-radius: 35rpx;
			}
		}
	}

	.ljshop-float-btn {
		position: fixed;
		bottom: calc(var(--window-bottom) + 100rpx);
		right: 30rpx;
		z-index: 9999;
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;

		.btn-item {
			margin-bottom: 20rpx;
			background: "#ff0000";

			.btn-img {
				margin-top: 20rpx;
				width: 80rpx;
				height: 80rpx;
			}

			.btn-name {
				font-size: 26rpx;
				color: #fff;
				text-align: center;
				white-space: nowrap;
			}
		}

	}

	.img-box {
		position: relative;
		width: 610rpx;

		.modal-img {
			width: 100%;
			will-change: transform;
			height: 830rpx;
		}
	}
	.onSubsidy{
		border-radius: 35rpx !important;
		width: 450rpx !important;
        background-color: rgba(248, 47, 47, 1);
	}
  .top-box{
    background-color: #fff;
    padding: 20rpx 20rpx 0 20rpx;
    font-weight: 600;
    font-size: 27rpx;
  }
  .bottom-box{
    display: flex;
    justify-content: space-between;
    padding: 20rpx 20rpx 20rpx 20rpx;
    background-color: #fff;
    font-size: 24rpx;
    color: black;

  }
  // 商铺盒子
  .store-box{
    width: 100%;
    height: 150rpx;
    padding: 20rpx;
    margin-bottom: 20rpx;
    display: flex;
    background-color: #fff;
    justify-content: space-between;
    align-items: center;
    border-radius: 20rpx;
    .store-left{
      display: flex;
      margin-left: 10rpx;
      .img-box{
        width: 100rpx;
        height: 100rpx;
        //background-color: #ff5555;
        border-radius: 50%;
        overflow: hidden;
        text-align: center;
        line-height: 100rpx;
        color: #fff;
        font-size: 30rpx;
      }
      .title-boxs{
        display: flex;
        flex-direction: column;
        //align-items: center;
        justify-content: center;
        margin-left: 30rpx;
      }
    }
    .store-right{
      margin-right: 20rpx;
      padding: 10rpx 25rpx 10rpx 25rpx;
      border: 1rpx solid #f66820;
      border-radius: 30rpx;
      color:#f66820 ;
      font-size: 24rpx;
    }
  }
  // 评论盒子
  .goods-comment{
    border-radius: 20rpx;
    overflow: hidden;
    margin-bottom: 20rpx;
  }
  // 秒杀盒子
  .rush-box{
    width: 100%;
    height: 150rpx;
    background: linear-gradient(90deg,#ee4b3a,#e5308f);
    display: flex;
    justify-content: space-between;
    align-items: center;
    // border-top-right-radius: 20rpx;
    // border-top-left-radius: 20rpx;
    padding: 10rpx 20rpx 10rpx 20rpx;
    color: #fff;
    .left{
        .topPrice{
            font-size: 35rpx;
            font-weight: 600;
            .sub{
                font-size: 20rpx;
                font-weight: 500;
                // 字体横线
                text-decoration: line-through;
                margin-left: 20rpx;
            }
        }
        .hot{
            margin-top: 10rpx;
            font-size: 24rpx;
			width: 100rpx;
			width: 120rpx;
			height: 50rpx;
        }
    }
    .right{
        display: flex;
        flex-direction: column;
        .pross{
            width: 250rpx;
            background: rgba(255,255,255,.2);
            position: relative;
            height: 30rpx;
            border-radius: 20rpx;
            // overflow: hidden;
            .line{
                border-radius: 20rpx;
                position: absolute;
                top: 0;
                left: 0;
                // width: 200rpx !important;
                height: 100%;
                background: #f66820;
            }
            .line::after{
                content: '';
                        position: absolute;
                        width: 45rpx;
                        height: 45rpx;
                        border-radius: 10rpx;
                        background: url('https://image.hzwltb69.com/app/date/2023/rushfire.png') no-repeat;
                        background-size: 100%;
                        top: -13rpx;
                        right: -23rpx;
            }
        }
        .num{
            margin-top: 10rpx;
            font-size: 24rpx;
            text-align: right;
        }
        .times{
            margin-top: 20rpx;
            font-size: 24rpx;
            text-align: right;
        }
    }
  }
</style>